package com.hubt.controller;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hubt.common.PageBean;
import com.hubt.model.OrganTree;
import com.hubt.service.PtOrganService;
import com.hubt.vo.Organvo;

import net.sf.jsqlparser.statement.update.Update;

@Controller
@RequestMapping("/org")
public class PtOrganController {
	@Autowired
	private PtOrganService ptOrganService;
	
	@RequestMapping(value = "/getOrgs",method = RequestMethod.GET)
	@ResponseBody
	public PageBean<Organvo> fiandBean(@Param("pageSize") Integer pageSize,@Param("pageNumber") Integer pageNumber){
		PageBean<Organvo> pageBean=new PageBean<Organvo>();
		pageBean=ptOrganService.findbyPage(pageNumber, pageSize);
		return pageBean;
	}

	@RequestMapping(value = "/getOrgsByParentId",method = RequestMethod.GET)
	@ResponseBody
	public OrganTree findByParentId(@Param("parentUUID") String parentUUID) {
		OrganTree organTree=new OrganTree();
		organTree=ptOrganService.findByparent(parentUUID);
		return organTree;
	}
	
	@RequestMapping(value = "/insert",method = RequestMethod.POST)
	@ResponseBody
	public boolean insert(@Param("form") Organvo organvo) {
		
		return ptOrganService.insert(organvo);
	}
	
	
	@RequestMapping(value = "/update",method = RequestMethod.POST)
	@ResponseBody
	public boolean Update(@Param("form") Organvo organvo) {
		return ptOrganService.update(organvo);
	}
	
	@RequestMapping(value = "/getOrg",method = RequestMethod.GET)
	@ResponseBody
	public Organvo findbyId(@Param("uuid") String uuid) {
		Organvo organvo=new Organvo();
		organvo=ptOrganService.findbyId(uuid);
		return organvo;
	}
	
	@RequestMapping("/remove")
	@ResponseBody
	public boolean delete(@Param("id") String id) {
		return ptOrganService.delete(id);
	}
}
